🎖️GitЯра🎖️
.github/workflows/pull-request-target.yml a95cfdfb72d52ba893367593fb85b2b8c614f7fa (a95cfdfb) Text, 3.63 KB
Tff7b72nameTb4b4b4: Ta5d6ff"Ta5d6ffPullTe6edf3 Ta5d6ffRequestTe6edf3 Ta5d6ffLabelerTa5d6ff"
Tff7b72onTb4b4b4:
Tff7b72pull_request_targetTb4b4b4:
Tff7b72typesTb4b4b4: Tb4b4b4[Te6edf3openedTb4b4b4, Te6edf3synchronizeTb4b4b4]
T8b949e# Do not execute arbitrary code on this workflow.
T8b949e# See warnings at https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#pull_request_target
Tff7b72concurrencyTb4b4b4:
Tff7b72groupTb4b4b4: Ta5d6ff${{Ta5d6ff Ta5d6ffgithub.workflowTa5d6ff Ta5d6ff}}-${{Ta5d6ff Ta5d6ffgithub.event.pull_request.numberTa5d6ff Ta5d6ff}}
Tff7b72cancel-in-progressTb4b4b4: Ta5d6fftrue
Tff7b72jobsTb4b4b4:
Tff7b72labelerTb4b4b4:
Tff7b72permissionsTb4b4b4:
Tff7b72contentsTb4b4b4: Ta5d6ffread
Tff7b72pull-requestsTb4b4b4: Ta5d6ffwrite
Tff7b72runs-onTb4b4b4: Ta5d6ffubuntu-24.04-arm
Tff7b72stepsTb4b4b4:
Tb4b4b4- Tff7b72nameTb4b4b4: Ta5d6ffAuto-labelTa5d6ff Ta5d6ffPR
Tff7b72usesTb4b4b4: Ta5d6ffactions/github-script@v9
Tff7b72withTb4b4b4:
Tff7b72scriptTb4b4b4: Tb4b4b4|
Tff7b72const branch = context.payload.pull_request.head.ref;
Tff7b72const title = context.payload.pull_request.title || '';
Tff7b72const labels = new Set();
Tff7b72// Match branch prefix (e.g. feat/..., fix/..., chore-something)
Tff7b72// Also parse conventional-commit-style PR titles as a fallback
Tff7b72const branchPrefix = branch.split(/[\/\-_]/)[0].toLowerCase();
Tff7b72const titlePrefix = (title.match(/^(\w+)[\(:]/) || [])[1]?.toLowerCase();
Tff7b72const prefix = branchPrefix || titlePrefix;
Tff7b72// Map prefixes to changelog-aligned labels
Tff7b72const prefixMap = {
Tff7b72'feat': 'enhancement',
Tff7b72'feature': 'enhancement',
Tff7b72'fix': 'bugfix',
Tff7b72'bug': 'bugfix',
Tff7b72'bugfix': 'bugfix',
Tff7b72'hotfix': 'bugfix',
Tff7b72'refactor': 'refactor',
Tff7b72'chore': 'chore',
Tff7b72'build': 'build',
Tff7b72'ci': 'ci',
Tff7b72'test': 'testing',
Tff7b72'tests': 'testing',
Tff7b72'docs': 'documentation',
Tff7b72'doc': 'documentation',
Tff7b72'perf': 'enhancement',
Tff7b72'style': 'refactor',
Tff7b72'repo': 'repo',
Tff7b72'release': 'release',
Tff7b72};
Tff7b72// Label from branch prefix
Tff7b72if (prefixMap[branchPrefix]) labels.add(prefixMap[branchPrefix]);
Tff7b72// Label from PR title prefix (if different from branch)
Tff7b72if (titlePrefix && prefixMap[titlePrefix] && !labels.has(prefixMap[titlePrefix])) {
Tff7b72labels.add(prefixMap[titlePrefix]);
Tff7b72}
Tff7b72// Also label 'repo' if .github/ or build-logic/ files were changed
Tff7b72if (!labels.has('repo') && !labels.has('ci') && !labels.has('build')) {
Tff7b72try {
Tff7b72const files = await github.paginate(
Tff7b72github.rest.pulls.listFiles,
Tff7b72{ owner: context.repo.owner, repo: context.repo.repo, pull_number: context.payload.pull_request.number, per_page: 100 },
Tff7b72(res) => res.data.map(f => f.filename)
Tff7b72);
Tff7b72if (files.some(f => f.startsWith('.github/'))) labels.add('repo');
Tff7b72if (files.some(f => f.startsWith('build-logic/'))) labels.add('build');
Tff7b72} catch (e) {
Tff7b72core.warning(`Could not list PR files (rate limited?): ${e.message}`);
Tff7b72}
Tff7b72}
Tff7b72if (labels.size > 0) {
Tff7b72const labelArray = [...labels];
Tff7b72core.info(`Applying labels: ${labelArray.join(', ')}`);
Tff7b72try {
Tff7b72await github.rest.issues.addLabels({
Tff7b72owner: context.repo.owner,
Tff7b72repo: context.repo.repo,
Tff7b72issue_number: context.payload.pull_request.number,
Tff7b72labels: labelArray,
Tff7b72});
Tff7b72} catch (e) {
Tff7b72core.warning(`Could not apply labels (rate limited?): ${e.message}`);
Tff7b72}
Tff7b72} else {
Tff7b72core.info('No labels matched for this PR.');
Tff7b72}
Served by rngit 1.5.2 - Generated in 0.1s